﻿<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8" />
    <title>资料导出</title>
    <link href="../../../css/main.css" rel="stylesheet" type="text/css" />
    <link
      href="../../../bstable/css/bootstrap.min.css"
      rel="stylesheet"
      type="text/css"
    />
    <link
      href="../../../bstable/css/bootstrap-table.css"
      rel="stylesheet"
      type="text/css"
    />
    <link
      href="../../../css/bootstrap-select.min.css"
      rel="stylesheet"
      type="text/css"
    />
    <link
      href="../../../css/bootstrap.min.css"
      rel="stylesheet"
      type="text/css"
    />
    <style>
      input[name="btSelectAll"] {
        position: relative;
        bottom: 7px;
      }

      input[name="btSelectAll"]::after {
        content: "全选";
        color: #000;
        position: relative;
        left: 15px;
        bottom: 3px;
      }

      .bootstrap-table {
        padding: 20px;
      }
    </style>
  </head>

  <body>
    <div class="tabe_div">
      <p
        class="p_line text_ient"
        style="margin-bottom: -10px; border-bottom: 0"
      >
        <a class="find_a">学习形式：</a>
        <select
          id="xuexi"
          class="form_select studyMode selectpicker"
          style="padding-left: 1%; width: 150px"
          onchange="queryXLBatch(this)"
        >
          <option value="">全部</option>
        </select>
        <a class="find_a">学历层次：</a>
        <select
          class="form_select myeducation"
          style="padding-left: 1%; width: 150px"
          id="type"
          onchange="querySchool(this)"
        >
          <option value="">全部</option>
        </select>
        <a class="find_a">学校：</a>
        <select
          class="form_select myschool"
          style="padding-left: 1%; width: 150px"
          id="xuexiao"
          onchange="queryCourse(this)"
        >
          <option value="">全部</option>
        </select>
        <a class="find_a">专业：</a>
        <select
          class="form_select mycourse"
          style="padding-left: 1%; width: 150px"
          id="zhuanye"
        >
          <option value="">全部</option>
        </select>
        <a class="find_a">批次：</a>
        <select
          class="form_select mybatch"
          style="padding-left: 1%; width: 150px"
          id="xlpc"
        >
          <option value="">全部</option>
        </select>
        <input type="button" value="查询" class="but_find" id="search" />
      </p>
      <p class="p_line text_ient" style="margin-bottom: -10px">
        <a class="find_a">学生姓名：</a>
        <input
          type="text"
          id="name"
          class="form_input text_ient"
          placeholder="输入学生姓名"
        />
        <a class="find_a">学生身份证号：</a>
        <input
          type="text"
          id="card"
          class="form_input text_ient"
          placeholder="输入身份证号"
          maxlength="18"
        />
        <!-- <a class="find_a">学生手机号：</a>
            <input type="text" id="phone" class="form_input text_ient" placeholder="输入身份证号" maxlength="11" /> -->
      </p>
      <table
        data-url="json/data_alae_list.json"
        id="table"
        class="table_style"
        style="margin: 20px auto"
      ></table>

      <div style="text-align: center; margin: 20px auto">
        <input type="button" value="导出资料" class="but_find" id="ziliao" />
        <input type="button" value="导出表格" class="but_find" id="biaoge" />
      </div>
    </div>
    <script src="../../../js/jquery.js"></script>
    <script src="../../../js/common.js"></script>
    <script src="../../../js/laydate-master/laydate.js"></script>
    <script src="../../../bstable/js/bootstrap.min.js"></script>
    <script src="../../../bstable/js/bootstrap-table.js"></script>
    <script src="../../../bstable/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../../../js/bootstrap-select.min.js"></script>
    <script type="text/javascript">
      localStorage.setItem("name", "教务管理/资料导出");
      // 学历层次education，学校 school，专业train，批次batch
      $(function () {
        $("#search").on("click", function () {
          $("#table").bootstrapTable("refresh");
        });

        $(".selectpicker").selectpicker("refresh");

        $("#table").bootstrapTable({
          method: "get",
          striped: true,
          singleSelect: false,
          url: baseUrl + "studentInfo/getStudentList",
          dataType: "json",
          pagination: true, //分页
          sidePagination: "server",
          pageSize: 10,
          pageNumber: 1,
          search: false, //显示搜索框
          contentType: "application/x-www-form-urlencoded",
          ajaxOptions: {
            headers: {
              Authorization: JSON.parse(localStorage.getItem("userInfo")).token,
            },
          },
          checkbox: true,
          queryParams: function (params) {
            params.trainType = "education";
            params.studyMode = $("#xuexi").val().trim();
            params.educationName = $("#type").val().trim();
            params.schoolName = $("#xuexiao").val().trim();
            params.majorName = $("#zhuanye").val().trim();
            params.batch = $("#xlpc").val().trim();
            params.name = $("#name").val().trim();
            params.idNo = $("#card").val().trim();
            // params.mobile = $('#phone').val().trim()
            params.userType = "ziliao";
            params.offset = params.offset / params.limit;
            return params;
          },
          responseHandler: function (res) {
            var list = res.data.result.records;
            var maps = {
              education: "学历提升",
              occupation: "职业技能",
              title: "职称评审",
              train: "执业资格",
            };
            var commits = [
              "已保存",
              "已提交",
              "财务驳回",
              "教务驳回",
              "待财务审核",
              "待教务审核",
              "教务确认",
            ];
            list.forEach(function (item, i) {
              item.trainType = maps[item.trainType];
              item.commitFlag = commits[item.commitFlag];
              !item && (list[i] = {});
              item.feeFlag = item.feeFlag == 1 ? "已缴费" : "未缴费";
            });
            return {
              rows: list,
              total: res.data.total,
            };
          },
          columns: [
            {
              checkbox: true,
              width: 80,
            },
            {
              field: "no",
              title: "序号",
              sortable: true,
              align: "center",
              formatter: function (value, row, index) {
                var pageSize =
                  $("#table").bootstrapTable("getOptions").pageSize;
                var pageNumber =
                  $("#table").bootstrapTable("getOptions").pageNumber;
                return pageSize * (pageNumber - 1) + index + 1;
              },
            },
            {
              title: "学生姓名",
              field: "name",
              align: "center",
              valign: "middle",
            },
            {
              title: "身份证号",
              field: "idNo",
              align: "center",
            },
            {
              title: "老师手机号",
              field: "teacherMobile",
              align: "center",
            },
            {
              title: "老师姓名",
              field: "teacherName",
              align: "center",
            },
            {
              title: "报考类型",
              field: "trainType",
              align: "center",
            },
            {
              title: "提交日期",
              field: "term",
              align: "center",
            },
            // {
            //     title: '课程开始时间',
            //     field: 'classStartDate',
            //     align: 'center'
            // },
            // {
            //     title: '课程结束时间',
            //     field: 'classEndDate',
            //     align: 'center'
            // },
            {
              title: "审核状态",
              field: "commitStr",
              align: "center",
            },
          ],
        });
      });
      $("#ziliao").on("click", function () {
        var rows = $("#table").bootstrapTable("getSelections");
        var studentId = [];
        if (!rows.length) {
          return alert("请至少选择一项");
        }
        console.log(rows);
        rows.forEach(function (item) {
          studentId.push(item.name + "_" + item.idNo);
        });
        window.open(
          baseUrl +
            "studentInfo/dataExport" +
            "?studentId=" +
            studentId.join(",")
        );
        return false;
      });

      function transformRequest(obj) {
        //console.log('obj',obj)
        var str = [];
        for (var p in obj) {
          str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
        }
        //console.log(str.join("&"))
        return str.join("&");
      }

      $("#biaoge").on("click", function () {
        var rows = $("#table").bootstrapTable("getSelections");
        var studentId = [];
        if (!rows.length) {
          return alert("请至少选择一项");
        }
        rows.forEach(function (item) {
          studentId.push(item.id);
        });
        window.open(
          baseUrl + "studentInfo/sheetExport" + "?studentIds=" + studentId
        );
      });

      $.ajax({
        url: baseUrl + "education/queryModeList",
        async: false,
        method: "Post",
        headers: {
          Authorization: JSON.parse(localStorage.getItem("userInfo")).token,
        },
        success: function (data) {
          var html_ = '<option value="0">请选择</option>';
          for (var i = 0; i < data.length; i++) {
            html_ +=
              '<option  value="' +
              data[i].id +
              '" >' +
              data[i].mode +
              "</option>";
          }
          $(".studyMode").html(html_);
        },
      });

      $.ajax({
        url: baseUrl + "education/queryEducationList",
        async: false,
        method: "Post",
        headers: {
          Authorization: JSON.parse(localStorage.getItem("userInfo")).token,
        },
        success: function (data) {
          var html_ = '<option value="0">请选择</option>';
          for (var i = 0; i < data.length; i++) {
            html_ +=
              '<option  value="' +
              data[i].id +
              '" >' +
              data[i].educationName +
              "</option>";
          }
          $(".myeducation").html(html_);
        },
      });

      function querySchool(obj) {
        $.ajax({
          url: baseUrl + "education/querySchoolList",
          method: "Post",
          data: "educationId=" + obj.value,
          headers: {
            Authorization: JSON.parse(localStorage.getItem("userInfo")).token,
          },
          success: function (data) {
            var html_ = '<option value="0">请选择</option>';
            for (var i = 0; i < data.length; i++) {
              html_ +=
                '<option  value="' +
                data[i].id +
                '" >' +
                data[i].schoolName +
                "</option>";
            }
            $(".myschool").html(html_);
          },
        });
      }

      function queryCourse(obj) {
        $.ajax({
          url: baseUrl + "education/queryCourseList",
          method: "Post",
          data: "schoolId=" + obj.value,
          headers: {
            Authorization: JSON.parse(localStorage.getItem("userInfo")).token,
          },
          success: function (data) {
            var html_ = '<option value="0">请选择</option>';
            for (var i = 0; i < data.length; i++) {
              html_ +=
                '<option  value="' +
                data[i].id +
                '" >' +
                data[i].courseName +
                "</option>";
            }
            $(".mycourse").html(html_);
            //alert(data[0].educationName);
          },
        });
      }

      function queryXLBatch(obj) {
        $.ajax({
          url: baseUrl + "education/queryBatchList",
          method: "Post",
          data: {
            pid: $(obj).val(),
            trainType: "education",
          },
          success: function (data) {
            var html_ = '<option value="0">请选择</option>';
            for (var i = 0; i < data.length; i++) {
              html_ +=
                '<option  value="' +
                data[i].id +
                '" >' +
                data[i].batch +
                "</option>";
            }
            $("#xlpc").html(html_);
            $(".selectpicker").selectpicker("refresh");
          },
        });
      }
    </script>
  </body>
</html>
